package librus.control
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.ProgressEvent;
	
	import librus.view.ProgressBox;
	
	import mx.managers.PopUpManager;

	public class ProgressManager extends EventDispatcher
	{
		public function ProgressManager()
		{
		}
		
		private var __progress:ProgressBox;
		
		
		public function show(value:Boolean,parent:DisplayObject=null):void
		{
			if (!__progress)
			{
				__progress = new ProgressBox(this); 
				__progress.width = 300;
				__progress.height = 150;
			}
			
			if (value)
			{
				PopUpManager.addPopUp(__progress,parent,true);
				PopUpManager.centerPopUp(__progress);
			}
			else
			{
				PopUpManager.removePopUp(__progress);
			}
		}
		
		public function setProgress(progress:int, total:int):void
		{
			dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,progress,total));	
		}
		
		public function setComplete():void
		{
			dispatchEvent(new Event(Event.COMPLETE));
		}
	}
}